const path = require("path");
const name = 'mapView'

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  publicPath:process.env.NODE_ENV === 'production' ? './' : '/',
  productionSourceMap:false,
  lintOnSave: false,
  chainWebpack: config => {
    config.plugins.delete('prefetch');
    const svgRule = config.module.rule("svg");
    svgRule.uses.clear();
    svgRule
      .test(/.svg$/)
      .include.add(path.resolve(__dirname, "./src/icons/svg"))
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "icon-[name]"
      });
    const fileRule = config.module.rule("file");
    fileRule.uses.clear();
    fileRule
      .test(/.svg$/)
      .exclude.add(path.resolve(__dirname, "./src/icons/svg"))
      .end()
      .use("file-loader")
      .loader("file-loader");
  },
  devServer: {
    // host: "127.0.0.1",//本地的ip地址
    // port: 8080, // 端口号
    https: false, // https:{type:Boolean}
    open: true, //配置自动启动浏览器
    proxy: {
      '/api': {
        target: process.env.VUE_APP_BASE_API,
        // target: 'http://60.168.132.92:9880',
        changeOrigin: true,
        pathRewrite: {
          ['^' + '/api']: ''
        }
      },
      '/ocr': {
        target: process.env.VUE_APP_OCR_API,
        // target: 'http://60.168.132.92:9880',
        changeOrigin: true,
        pathRewrite: {
          ['^' + '/ocr']: '/ocr'
        }
      },
    }
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    name: name,
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
  },
};
